#ifndef CM_RGB24_H_
#define CM_RGB24_H_

#include <cm/img/cm_img.h>

static inline size_t rgb24_data_total(unsigned w, unsigned h)
{
	return (w * h * 3);
}

static inline int rgb24_r_offset(unsigned x, unsigned y, unsigned w, unsigned h)
{
	if (VALID_AREA(x, y, w, h))
		return (int) ((y * w + x) * 3);
	else
		return -1;
}
/* g b的偏移请在上面结果的基础上加1或2， bgr格式同理
static inline int rgb24_g_offset(unsigned x, unsigned y, unsigned w, unsigned h);
static inline int rgb24_b_offset(unsigned x, unsigned y, unsigned w, unsigned h);
*/

static inline int bgr24_b_offset(unsigned x, unsigned y, unsigned w, unsigned h)
{
	if (VALID_AREA(x, y, w, h))
		return (int) ((y * w + x) * 3);
	else
		return -1;
}

#endif /* CM_RGB24_H_ */
